<template>
	<view class="tab-bar">
		<view class="tab-bar-item" v-for="(item,index) in tabBar" :key="index"
			@click="clickTabbar(item.pagePath,index)">
			<view class="tab-img">
				<image :src="item.iconPath" mode=""></image>
			</view>
			<text :class="{ 'active-text': currentIndex === index }">{{item.text}}</text>

		</view>

	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';

	const props = defineProps({
		currentIndex: {
			type: Number,
			default: 0
		}
	});
	const tabBar = [{
			pagePath: "pages/index/index",
			text: "首页",
			iconPath: "/static/tabar-icon/tabar-1.png",

		},
		{
			pagePath: "pages/record/record",
			text: "记录",
			iconPath: "/static/tabar-icon/tabar-2.png",

		},
		{
			pagePath: "pages/my/my",
			text: "我的",
			iconPath: "/static/tabar-icon/tabar-3.png",

		}
	]

	const clickTabbar = (path, index) => {
		uni.switchTab({
			url: `/${path}`
		})
	}
</script>

<style scoped lang="scss">
	.tab-bar {
		width: calc(100vw - 60rpx);
		padding: 0 30rpx;
		height: 60px;
		position: fixed;
		bottom: 0;
		left: 0;
		background-color: #fff;
		padding-bottom: env(safe-area-inset-bottom);
		z-index: 10;
		box-shadow: 0 0 3px -1px gray;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 14px;

	}

	.tab-bar-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		flex: 1;
		justify-content: center;
		height: 100%;
		padding: 8px 0px;
		box-sizing: border-box;

	}

	.tab-img {
		width: 20px;
		height: 20px;
		margin-bottom: 4px;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.active-text {
		color: #3C75E5;
	}
</style>